Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more ways to collect Nav Areas #42

Merged
merged 5 commits into from
Aug 3, 2023
Merged

Conversation

KitRifty
Copy link
Collaborator

@KitRifty KitRifty commented Jul 31, 2023

This PR adds several new ways to collect areas in the navigation mesh.

  • Added CollectAreasOverlappingExtent and CollectAreasInRadius natives to CNavMesh. Their equivalents in VScript are NavMesh.GetNavAreasOverlappingEntityExtent (but less restrictive) and NavMesh.GetNavAreasInRadius, respectively.
  • Added CollectAreasAlongLine, which as the name states, starts at an area and collects areas along the mesh towards the ending area in a straight line.
    • This should not be confused with BuildPath as it doesn't do any path making whatsoever.
  • Added GetAdjacentLength and GetIncomingConnectionLength to CNavArea, which returns the length of the connection between the areas' centers. This is a cached value.
    • This can be useful for custom area collection algorithms and alleviates the need of having to manually calculate the distance repeatedly (i.e getting both areas' centers, then doing GetVectorDistance, etc).
  • Fixed a minor typo of GetIncomingConnection's C++ native function.

With the new collection methods, I'm not sure if SurroundingAreasCollector needs a new name or not.

Add CNavArea.GetAdjacent/IncomingConnectionLength
Copy link
Collaborator

@Kenzzer Kenzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's too late to correct the existence of SurroundingAreasCollector but we could simply extend it through a methodmap like so methodmap AreasCollector < SurroundingAreasCollector, we avoid the creation of new natives, while staying bcompat.

Good PR, and good natives addition otherwise.

extension/natives/nav.cpp Outdated Show resolved Hide resolved
extension/natives/nav/area.cpp Outdated Show resolved Hide resolved
extension/natives/nav/area.cpp Outdated Show resolved Hide resolved
extension/natives/nav/area.cpp Outdated Show resolved Hide resolved
@KitRifty KitRifty requested a review from Kenzzer August 2, 2023 01:23
@Kenzzer Kenzzer merged commit b5dd18a into master Aug 3, 2023
7 checks passed
@Kenzzer Kenzzer deleted the nav-collection-length branch August 3, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants